package loginactivity;

import com.ronipl.createtabs.R;
import com.ronipl.createtabs.R.id;
import com.ronipl.createtabs.R.layout;
import com.ronipl.createtabs.R.menu;
import com.ronipl.formalisticsv2.MainActivity;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ProgressBar;

public class LoginActivity extends Activity {
	
	Button loginBtn;
	ProgressBar loginLoading;
	ProgressDialog progress;
	
	public static int SPLASH_TIME_OUT = 3000;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		
		loginBtn = (Button)findViewById(R.id.loginBtn);
		
		
		loginBtn.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				
				progress = new ProgressDialog(v.getContext());
				//progress.setTitle("Logging in");
				progress.setMessage("Logging in");
				progress.setCancelable(true);
				progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
				progress.show();
				//progress.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
		
				new Handler().postDelayed(new Runnable(){

					@Override
					public void run() {
						
						Intent i = new Intent(LoginActivity.this, MainActivity.class);
						startActivity(i);
						finish();
					}
					
				}, SPLASH_TIME_OUT);
				
			}
			
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
